package com.atguigu.springbootwebflux01.config;

import com.alibaba.fastjson2.support.config.FastJsonConfig;
import com.alibaba.fastjson2.support.spring6.http.codec.Fastjson2Decoder;
import com.alibaba.fastjson2.support.spring6.http.codec.Fastjson2Encoder;
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.util.MimeType;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import com.alibaba.fastjson2.*;

import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;

/**
 * @Package com.atguigu.springbootwebflux01.config
 * @Program: springboot-part
 * @ClassName WebConfig
 * @Description[类型描述] 配置Webflux服务
 * @Author: 霍杰
 * @CreateTime 2024/11/20
 * @Version 1.0
 * @Update [序号][ 日期YYYY-MM-DD][更改人姓名][变更描述]
 **/
@Configuration
public class WebConfig implements WebFluxConfigurer {
    @Override
    public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
        ObjectMapper mapper = new ObjectMapper();
        FastJsonConfig fastJsonConfig = new FastJsonConfig();

        //MimeType  mimeTypes = new MimeType();
        configurer.defaultCodecs().jackson2JsonDecoder(new Fastjson2Decoder(mapper, fastJsonConfig));
        configurer.defaultCodecs().jackson2JsonEncoder(new Fastjson2Encoder(mapper, fastJsonConfig));
    }


}
